<?php
//aa
class Validator extends CI_Controller {
	function __construct(){ // loadcontroller parent 
		parent::__construct(); // load 'url' helper
		$this->load->helper( 'url' ); // load 'form' helper
		$this->load->helper( 'form' ); // load 'validation' class
		$this->load->library( 'form_validation' );
	}
	function index() { // set validation rules 
//		$rules ['firstname'] = "required";
//		$rules ['lastname'] = "required";
//		$rules ['email'] = "required";
//		$this->form_validation->set_rules( $rules ); // check if form has been submitted properly
		$this->form_validation->set_rules('firstname', 'First Name', 'required|min_length[6]|max_length[15]'); 
		$this->form_validation->set_rules('lastname', 'Last Name', 'required'); 
		$this->form_validation->set_rules('email', 'email', 'required'); 
		 
		if ($this->form_validation->run () == FALSE) { // redisplay web form 
			$this->load->view('form_view');
		} // display success web page
		else {
			$this->load->view('success_view');
		}
	}
}
?>